﻿using System;
using System.Data;
using System.Collections.Generic;
using KPIS.DBM;
using KPIS.GERP.GHRMS.MODEL;
using KPIS.GERP.GHRMS.IDAL;
//using MySql.Data;
using System.Data.Odbc;
//using MySql.Data.MySqlClient;
using System.Data.SqlClient;

namespace KPIS.GERP.GHRMS.DAL
{
    public class ComponentEvaluateDAL : IComponentEvaluateDAL
    {
        private IDBManager dbManager = new DBManager(SystemInfo._DataProvider, SystemInfo._ConnectionString);
        //private MySqlConnection conn = new MySqlConnection(SystemInfo._ConnectionString);
        SqlConnection conn = new SqlConnection(SystemInfo._ConnectionString);
        public DataTable LoadJobSite(int? emp_seq, int? round_seq)
        {
            try
            {
                conn.Open();
                //MySqlCommand cmd = new MySqlCommand();
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = conn;
                cmd.CommandText = "hr_sp_evaluate_orgchart_sel";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@intEmpSeq", emp_seq);
                cmd.Parameters.AddWithValue("@intRoundSeq", round_seq);
                cmd.Parameters.AddWithValue("@vharRecordStatus", SystemInfo._DeleteRecordStatus);

                //MySqlDataAdapter da = new MySqlDataAdapter(cmd);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable dtb = new DataTable();
                da.Fill(dtb);

                return dtb;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }

        public DataTable LoadRound()
        {
            string strSQL;

            try
            {
                dbManager.Open();
                dbManager.CreateParameters(1);

                dbManager.AddParameters(0, "@status", SystemInfo._DeleteRecordStatus);

                strSQL = " SELECT evaluation_round_seq,CONCAT(round_no,'/',round_year) evaluation_round "
                         + " FROM hrd_evaluation_round "
                         + " where record_status != @status "
                         + " ORDER BY round_year DESC ,round_no ";

                DataTable dtb = dbManager.ExecuteDataSet(CommandType.Text, strSQL).Tables[0];
                return dtb;

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                dbManager.Dispose();
            }
        }
    }
}
    